﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Payroll.BusinessLogic;
using Payroll.Common.Utils;
using PayrollHR.Web;
using Payroll.BusinessLogic.CustomerManager;
using Payroll.BusinessLogic.Customer;

namespace PayrollHR.Administration.Modules
{
    public partial class ListCustomerResult : BasePayrollAdministrationUserControl
    {
        private const int m_pageSize = 50;
        protected void Page_Load(object sender, EventArgs e)
        {
           
                if (!IsPostBack)
                {
                   
                    LoadGrid();
                    
                }
            
        }
        protected void BindGrid()
        {
            var customers = GetCustomersResult();
            gvCustomersResult.DataSource = customers;
            gvCustomersResult.DataBind();
        }
        protected void LoadGrid()
        {
            
                var customersResult = LoadCustomersResult();
                gvCustomersResult.DataSource = customersResult;
                gvCustomersResult.DataBind();

            
        }
        protected List<CustomerResult> GetCustomersResult()
        {
            CustomerSearchResult customerColection = CustomerResultSearch1.GetCustomerSearch();
            List<CustomerResult> customerResult = CustomerService.GetAllCustomerResult(customerColection, m_pageSize);
            return customerResult;
        }
        protected List<CustomerResult> LoadCustomersResult()
        {
            int Useid = PayrollContext.Current.Session.EmployeeId;
            CustomerSearchResult customerColection = new CustomerSearchResult
            {
                CustName = "",

                CutomerTypeId = 0,

                UserId = Useid,
                PackageName="",
                TaxCode="",
                PackageCode=""
            };
            List<CustomerResult> customerResult = CustomerService.GetAllCustomerResult(customerColection,m_pageSize);

           // List<Customer> customer = CustomerService.GetAllCustomer(customerColection, m_pageSize);
            return customerResult;
        }
        protected void gvCustomersResult_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            gvCustomersResult.PageIndex = e.NewPageIndex;
            BindGrid();
        }
    
        protected void SearchButton_Click(object sender, EventArgs e)
        {
            this.BindGrid();
        }
        protected void btnSend_Click(object sender, EventArgs e)
        {
        }
      
    }
}